package com.balabala.gym_system.config;

import com.balabala.gym_system.pojo.entity.Admin;

/**
 * Author:zl
 * Date:2023/5/1 13:30
 */

public class AdminThreadLocal {
    private static ThreadLocal<Admin> tl=new ThreadLocal<Admin>();

    /**
     * 绑定管理员到当前线程
     * @param admin
     */
    public static void setAdmin(Admin admin){
        tl.set(admin);
    }

    /**
     * 获取当前线程绑定的管理员
     * @return
     */
    public static Admin get(){
        return tl.get();
    }


    /**
     * 移除当前线程绑定的管理员
     */
    public static void  remove(){
        tl.remove();
    }
}
